/**
 * Created by yongyuehuang on 2016/12/15.
 */
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import '../assets/less/homeList.less'
import {agentImageURL} from '../utils'

export class HomeList extends React.Component {
    render() {
        const {id, title, imgUrl} = this.props
        return (
            <div className="home-list-wrapper">
            <Link to={`/newsDetail/${id}`} className="home-list-wrap">
                <div className="left">
                    {title}
                </div>
                {imgUrl ? <div className="right" style={{'backgroundImage': 'url(' + agentImageURL(imgUrl) + ')'}}>
                </div> : ''}
            </Link>
            </div>
        )
    }
}

//数据验证
HomeList.propTypes = {
    id: PropTypes.number.isRequired,
    imgUrl: PropTypes.string.isRequired,
    title: PropTypes.string.isRequired
}